<?php


namespace App\Http\Model;


use Illuminate\Support\Facades\DB;

class NotifyModel extends Base
{
    protected $table = 'send_alluser_notify';
    protected $logTable = 'send_alluser_notify_log';

    public function __construct(array $attributes = [])
    {
        parent::__construct($this->table, $attributes);
    }
    
    /**
     * 新建推送/修改推送
     */
    public function insertOrUpnotify($data=[])
    {
        if(isset($data['id']) && !empty($data['id']))
        {
            $id = $data['id'];
            unset($data['id']);
            $res = DB::table($this->table)->where('id',$id)->update($data);
        }else{
            $res =  DB::table($this->table)->insert($data);
        }
       
       return $res;
    }
    /**
     * 删除推送
     */
    public function deleteNotify($notifyid,$status){
        $res = DB::table($this->table)->where('id',$notifyid)->update(['is_delete'=>$status]);
        return $res;
    }
    
    //更新记录
    public function insertNotifyLog($data){
        $res = DB::table($this->logTable)->insert($data);
        return $res;
    }
}